﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MsTestUtilities.Utilities;
using MsTestUtilities.RowTests;

namespace MsTestUtilitiesTests.Utilities.PathUtilitiesTests
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void DoubleDotCollapse()
        {
            new TestScenarioBuilder<string, string>()
                .For(PathUtilities.Collapse)
                .Given(@"c:\somedir\file.txt").Expect(@"c:\somedir\file.txt").Because("When input doesn't contain double dots it's returned.")
                .Given(@"c:\somedir\..\file.txt").Expect(@"c:\file.txt").Because("Double dots move one directory up.")
                .Given(@"c:\somedir\otherDir\..\..\file.txt").Expect(@"c:\file.txt").Because("Multiple double dots add up.")
                .Given(@"c:\somedir\..\otherDir\..\file.txt").Expect(@"c:\file.txt").Because("Multiple series of double dots are handled.")
                .Given(@"somedir\..\..\otherDir\file.txt").Expect(@"..\otherDir\file.txt").Because("Extra double dots are left in the path.")
                .Given(@"c:\somedir\..\..\otherDir\file.txt").Expect(@"c:\..\otherDir\file.txt").Because("The root is not touched.")
                .Evaluate();            
        }
    }
}
